package com.wmjsoft.plugins.security.base


object CurrentThreadVariable {

    /**
     * 当前线程用户
     */
    private val userHolder: ThreadLocal<Int> = ThreadLocal<Int>()

    /**
     * 设置当前线程的用户
     *
     * @param user user
     */
    fun setCurrentThreadVariable(count: Int?) {
        userHolder.set(count)
    }

    /**
     * 取得当前线程中的用户
     */
    fun getCurrentThreadVariable(): Int {
        return userHolder.get()
    }

    /**
     * 清除当前线程用户
     */
    fun clearCurrentThreadVariable() {
        userHolder.remove()
    }


}